//package com.ruoyi.quartz.task;
///*
// * @ClassName MeetingTask
// * @Description //TODO
// * @Author Administrator
// * @Date 2024/4/3 15:20
// **/
//
//import cn.hutool.core.date.DateUtil;
//import com.ruoyi.common.utils.DateUtils;
//import com.ruoyi.common.utils.StringUtils;
//import com.ruoyi.system.domain.ActivityManagement;
//import com.ruoyi.system.domain.MeetingCollect;
//import com.ruoyi.system.domain.MeetingManagement;
//import com.ruoyi.system.domain.MeetingSummary;
//import com.ruoyi.system.service.IMeetingCollectService;
//import com.ruoyi.system.service.IMeetingManagementService;
//import com.ruoyi.system.service.IMeetingSummaryService;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.scheduling.annotation.Scheduled;
//import org.springframework.stereotype.Component;
//
//import java.util.Date;
//import java.util.List;
//
//@Slf4j
//@Component
//public class MeetingTask {
//
//    @Autowired
//    private IMeetingManagementService meetingManagementService;
//    @Autowired
//    private IMeetingSummaryService meetingSummaryService;
//    @Autowired
//    private IMeetingCollectService meetingCollectService;
//
//
//    /**
//     * 召开会议任务
//     */
//    @Scheduled(cron = "0 */1 * * * ?")
//    public void meetingStartTask(){
//        MeetingManagement meetingManagement = new MeetingManagement();
//        meetingManagement.setStatus("0");
//        List<MeetingManagement> meetingManagementList = meetingManagementService.selectMeetingSignaturelist(meetingManagement);
//        for(MeetingManagement meeting : meetingManagementList){
//            String meetingStartTime = meeting.getMeetingStartTime();
//            Date meetingStartDate = DateUtil.parse(meetingStartTime, "yyyy-MM-dd HH:mm:ss");
//            Date nowDate = DateUtils.getNowDate();
//            int compare1 = DateUtil.compare(meetingStartDate, nowDate);
//            String meetingEndTime = meeting.getMeetingEndTime();
//            Date meetingEndDate = DateUtil.parse(meetingEndTime, "yyyy-MM-dd HH:mm:ss");
//            int compare2 = DateUtil.compare(meetingEndDate, nowDate);
//            //如果当前时间在会议开始时间和结束时间范围内
//            if(compare1<0&&compare2>0){
//                Long id = meeting.getId();
//                MeetingManagement meetingManagementVo = new MeetingManagement();
//                meetingManagementVo.setId(id);
//                //进行中
//                meetingManagementVo.setStatus("1");
//                meetingManagementService.updateMeetingManagement(meetingManagementVo);
//            }
//            if(compare2<0){
//                Long id = meeting.getId();
//                MeetingManagement meetingManagementVo = new MeetingManagement();
//                meetingManagementVo.setId(id);
//                //结束（已召开未归档）
//                meetingManagementVo.setStatus("2");
//                meetingManagementService.updateMeetingManagement(meetingManagementVo);
//            }
//        }
//    }
//
//
//    /**
//     * 结束会议任务
//     */
//    @Scheduled(cron = "0 */1 * * * ?")
//    public void meetingEndTask(){
//        MeetingManagement meetingManagement = new MeetingManagement();
//        meetingManagement.setStatus("1");
//        List<MeetingManagement> meetingManagementList = meetingManagementService.selectMeetingSignaturelist(meetingManagement);
//        for(MeetingManagement meeting : meetingManagementList){
//            Date nowDate = DateUtils.getNowDate();
//            String meetingEndTime = meeting.getMeetingEndTime();
//            Date meetingEndDate = DateUtil.parse(meetingEndTime, "yyyy-MM-dd HH:mm:ss");
//            int compare = DateUtil.compare(meetingEndDate, nowDate);
//            //如果当前时间大于会议结束时间
//            if(compare<0){
//                Long id = meeting.getId();
//                MeetingManagement meetingManagementVo = new MeetingManagement();
//                meetingManagementVo.setId(id);
//                //会议结束（已召开未归档）
//                meetingManagementVo.setStatus("2");
//                meetingManagementService.updateMeetingManagement(meetingManagementVo);
//            }
//        }
//    }
//
//    /**
//     * 修改进行中的会议纪要状态
//     */
//    @Scheduled(cron = "0 */1 * * * ?")
//    public void meetingSummaryTask(){
//        //查询进行中的会议纪要
//        MeetingSummary summary = new MeetingSummary();
//        summary.setStatus("0");
//        List<MeetingSummary> meetingSummarieList = meetingSummaryService.selectMeetingSummaryList(summary);
//        for(MeetingSummary meetingSummary : meetingSummarieList){
//            String summaryFile = meetingSummary.getSummaryFile();
//            String summaryImage = meetingSummary.getSummaryImage();
//
//            Date endTime = meetingSummary.getEndTime();
//            Date nowDate = DateUtils.getNowDate();
//            int compare = DateUtil.compare(nowDate, endTime);
//            MeetingSummary summaryVo = new MeetingSummary();
//            summaryVo.setId(meetingSummary.getId());
//            //当前时间大于截至时间
//            if(compare>0){
//                //文件未完成  会议纪要修改为延期
//                if(StringUtils.isBlank(summaryFile)&&StringUtils.isBlank(summaryImage)){
//                    summaryVo.setStatus("2");
//                    meetingSummaryService.updateMeetingSummaryStatus(summaryVo);
//                }
//            }else{
//                //文件已经上传 会议纪要修改为完成
//                if(StringUtils.isNotBlank(summaryFile)&&StringUtils.isNotBlank(summaryImage)){
//                    summaryVo.setStatus("1");
//                    meetingSummaryService.updateMeetingSummaryStatus(summaryVo);
//                }
//            }
//        }
//    }
//
//    /**
//     * 修改延期的会议纪要状态
//     */
//    @Scheduled(cron = "0 */1 * * * ?")
//    public void meetingSummaryLayTask(){
//        //查询延期的会议纪要
//        MeetingSummary summary = new MeetingSummary();
//        summary.setStatus("2");
//        List<MeetingSummary> meetingSummarieList = meetingSummaryService.selectMeetingSummaryList(summary);
//        for(MeetingSummary meetingSummary : meetingSummarieList){
//            MeetingSummary summaryVo = new MeetingSummary();
//            summaryVo.setId(meetingSummary.getId());
//            String summaryFile = meetingSummary.getSummaryFile();
//            String summaryImage = meetingSummary.getSummaryImage();
//            //文件已经上传 会议纪要修改为延期完成
//            if(StringUtils.isNotBlank(summaryFile)&&StringUtils.isNotBlank(summaryImage)){
//                summaryVo.setStatus("3");
//                summaryVo.setMeetingId(meetingSummary.getMeetingId());
//                meetingSummaryService.updateMeetingSummaryStatus(summaryVo);
//            }
//        }
//
//    }
//
//    /**
//     * 修改进行中的会议收集
//     */
//    @Scheduled(cron = "0 */1 * * * ?")
//    public void meetingCollectionTask(){
//        //查询进行中的会议收集
//        MeetingCollect meetingCollect = new MeetingCollect();
//        meetingCollect.setStatus("0");
//        List<MeetingCollect> meetingCollectList = meetingCollectService.selectMeetingCollectList(meetingCollect);
//        for(MeetingCollect collection : meetingCollectList){
//            MeetingCollect meetingCollectVo = new MeetingCollect();
//            meetingCollectVo.setId(collection.getId());
//            //如果全部提交则完成收集
//            Integer differenceCount = collection.getDifferenceCount();
//            Date endTime = collection.getEndTime();
//            Date nowDate = DateUtils.getNowDate();
//            int compare = DateUtil.compare(endTime, nowDate);
//            //当前时间大于截至时间
//            if(compare<0){
//                if(differenceCount > 0){
//                    meetingCollectVo.setStatus("2");
//                    meetingCollectService.updateMeetingCollectStatus(meetingCollectVo);
//                }
//
//            }else{
//                if(differenceCount == 0){
//                    meetingCollectVo.setStatus("1");
//                    meetingCollectService.updateMeetingCollectStatus(meetingCollectVo);
//                }
//            }
//        }
//    }
//
//    /**
//     * 修改延期的会议收集
//     */
//    @Scheduled(cron = "0 */1 * * * ?")
//    public void meetingCollectionLayTask(){
//        //查询延期的会议收集
//        MeetingCollect meetingCollect = new MeetingCollect();
//        meetingCollect.setStatus("2");
//        List<MeetingCollect> meetingCollectList = meetingCollectService.selectMeetingCollectList(meetingCollect);
//        for(MeetingCollect collection : meetingCollectList){
//            MeetingCollect meetingCollectVo = new MeetingCollect();
//            meetingCollectVo.setId(collection.getId());
//            //如果全部提交则完成收集
//            Integer differenceCount = collection.getDifferenceCount();
//            if(differenceCount == 0){
//                meetingCollectVo.setStatus("3");
//                meetingCollectService.updateMeetingCollectStatus(meetingCollectVo);
//            }
//        }
//
//    }
//}
